home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#)error.c 1.2 3/18/87
- */
- #include "error.h"
- #include "nodes.h"
-
- int numberOfSyntaxErrors, numberOfSemanticErrors;
- char error_buffer[256];
-
- int We_Are_Skipping = 0;
-
- void BeginSyntaxErrorMessage(flag)
- int flag;
- {
- register int i;
- fprintf(stdout, "\"%s\", line %d\n%s",
- currentFileName, nextLineNumber,
- (int) lineBuffer.buffer[0] == -1 ? "<EOF>\n" : lineBuffer.buffer);
- for (i = 0; i < currentPosition; i++) {
- if (lineBuffer.buffer[i] == '\t') (void) fputc('\t', stdout);
- else (void) fputc(' ', stdout);
- }
- fprintf(stdout, "^\n%s", flag ? "Syntax error: " : "");
- numberOfSyntaxErrors++;
- }
-
- IllegalCharacter(c)
- char c;
- {
- char *dummy = "z";
-
- if (We_Are_Skipping) return;
- BeginSyntaxErrorMessage(1);
- ErrorWrite("Illegal character in source ");
- *dummy = c;
- ErrorWrite(dummy);
- EndErrorMessage();
- }
-
- UnexpectedEndOfFile()
- {
- BeginSyntaxErrorMessage(1);
- ErrorWrite("unexpected end of file");
- EndErrorMessage();
- }
-
- void NotImplemented(p, s)
- NodePtr p;
- char *s;
- {
- BeginErrorMessage(p);
- ErrorWrite("Not Implemented: ");
- ErrorWrite(s);
- EndErrorMessage();
- }
-
- void CheckForErrors()
- {
- if (numberOfSyntaxErrors != 0 || numberOfSemanticErrors != 0) {
- fprintf(stdout, "Compilation aborted.\n");
- exit(1);
- }
- }
-
- /*VARARGS2*/
- void ErrorMessage(p, format, args)
- NodePtr p;
- char *format;
- int args;
- {
- BeginErrorMessage(p);
- _doprnt(format, &args, stdout);
- EndErrorMessage();
- }
-
- /*VARARGS2*/
- void WarningMessage(p, format, args)
- NodePtr p;
- char *format;
- int args;
- {
- BeginWarningMessage(p);
- _doprnt(format, &args, stdout);
- EndErrorMessage();
- }
-
- yyerror(s)
- char *s;
- {
- BeginSyntaxErrorMessage(0);
- ErrorWrite(s);
- EndErrorMessage();
- }
-